package com.bjpowernode.edu.domain;

import lombok.Data;


/*
设计用来以json格式字符串的方式响应给前端的对象
*/
@Data
public class AjaxResult {
    private boolean success;//声明处理请求是否成功
    private Integer state;//声明处理请求响应给前端的状态码
    private String message;//声明响应给前端用来提示用户的消息
    private Object content;//响应给前端用来展示的具体数据

    public static AjaxResult success(Object content) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setState(200);
        ajaxResult.setContent(content);
        ajaxResult.setMessage("响应成功");
        return ajaxResult;
    }
    public static AjaxResult success() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setState(200);
        ajaxResult.setMessage("响应成功");
        return ajaxResult;

    }
    public static AjaxResult fail(String message) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setState(-1);
        ajaxResult.setMessage(message);
        return ajaxResult;
    }

}
